Apache2 is the standard Linux web server. It deals with all of the http and https requests sent to the server and complies PHP scripts. PHP is a simpler programming language which offers the power of the more complex object orientated languages without some of the more complex data management issues. PHP is commonly used to develop dynamic web content, especially content based upon a database like MySQL.
In a practical sense, you must have Apache installed to use PHP on your server. If you do not have Apache currently installed, instructions can be found here.
Installing PHP
These instructions assume you have already setup an AWS instance and have an SSH client (like PuTTY) available.
- Log in to your instance via the SSH client. Transfer to the root user.
- Use YUM to install php
- Press "Y" when it asks if you want to install PHP
- Verify the installation occurred correctly by starting/restarting the httpd service
Summary of command line inputs
- $ sudo su
- $ yum install httpd
- .....
- Do you want to install PHP 5.x (Y/N): Y
- $ service httpd restart
Configuring PHP
The default configuration of PHP is just fine to use for 90% of applications. If you are going to be doing development on the server, it would be appropriate to make a few changes to the php.ini file for the particular development server. These changes should occur in the Apache2 hosting configurations ("/etc/httpd/conf.d/vhosts.conf" in the previous Apache2 instructions). The major setting you would want to change is turning off safe mode.